<!-- 支出单确认费用 -->
<template>
  <a-modal
    v-model:visible="showModal"
    @close="onClose"
    @before-ok="submitFn"
    title="费用明细"
    class="modal-dialog-wrapper"
    unmount-on-close
    :mask-closable="false"
    width="65vw"
  >
    <div class="fee-item-content">
      <div class="fee-list">
        <div>
          <div class="fee-tlt">
            <div class="tlt-name">
              <span class="tag-name">{{ form.costType == 1 ? '报销费用' : '支出费用' }}</span>
            </div>
            <div class="tlt-price">应付：{{ unitVal(form.amount, '元') }}</div>
          </div>
          <div>
            <div class="fee-msg">
              <div class="msg">
                <div class="msg-tlt"><span>支出单号：</span>{{ form.code || '-' }}</div>
                <div class="msg-tlt"><span>支出单类型：</span>{{ form.costTypeName || '-' }}</div>
                <div class="msg-tlt"><span>费用产生门店：</span>{{ form.feeOrgName || '-' }}</div>
                <div class="msg-tlt">
                  <span>关联工单号：</span>
                  <span v-if="form.workTypeName || form.workCode"> {{ form.workTypeName }} {{ form.workCode }} </span>
                  <span v-else>-</span>
                </div>
                <div class="msg-tlt">
                  <span>关联业务单号：</span>
                  <span v-if="form.businessTypeName || form.businessCode"> {{ form.businessTypeName }}{{ form.businessCode }} </span>
                  <span v-else>-</span>
                </div>
                <div class="msg-tlt"><span>申请备注：</span>{{ form.remark || '-' }}</div>
                <div class="msg-tlt"><span>收款方：</span>{{ form.customerName || '-' }}</div>
                <div class="msg-tlt"><span>收款方式：</span>{{ form.collectInExpWayName || '-' }}</div>
                <div class="msg-tlt"><span>账号：</span>{{ form.collectCard || '-' }}</div>
              </div>
            </div>
            <div class="line">
              <div></div>
            </div>

            <div class="fee-table" v-if="form.feeList">
              <div class="table-items" v-for="(item, index) in form.feeList" :key="index">
                <div class="item-row">
                  <div class="item-pro">{{ item.itemName }}</div>
                  <div class="item-pro">付款</div>
                  <div class="item-pro">{{ unitVal(item.amount, '元') }}</div>
                  <div class="item-pro item-date">{{ item.occurTime }}</div>
                  <div>{{ item.carId ? item.licenseNo : '-' }}</div>
                  <div>{{ item.carId ? item.carModel : '-' }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="all-cost">
          <div>待付：{{ unitVal(Math.abs(form.amount), '元') }}</div>
        </div>
      </div>
    </div>
    <template #footer>
      <a-space>
        <a-button @click="onClose">关闭</a-button>
      </a-space>
    </template>
  </a-modal>
</template>

<script setup name="OperateCostFeeItem">
  import dayjs from 'dayjs'
  import { unitVal } from '@/utils'
  import { ref } from 'vue'

  const form = ref({})
  // 打开弹窗
  const showModal = ref(false)
  const open = (val) => {
    // 重置
    showModal.value = true
    form.value = val
    form.value.payTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
    form.value.customerName =
      val.collectType == '1' ? val.collectStaffName : val.collectType == '2' ? val.collectIndustryName : val.collectSupplierName
  }
  const onClose = () => {
    showModal.value = false
  }

  defineExpose({
    open,
  })
</script>

<style lang="less" scoped>
  // 弹窗添加的样式
  .fee-item-content {
    width: 100%;
    max-height: 70vh;
    position: relative;

    :deep(.arco-row) {
      margin-left: 0 !important;
      margin-right: 0 !important;
    }
    :deep(.arco-modal-body) {
      padding: 10px 80px !important;
    }
    :deep(.arco-col) {
      padding: 0 10px !important;
    }
    .fee-list {
      border: 1px solid #f2f3f5;
      .fee-tlt {
        width: 100%;
        height: 40px;
        background-color: #f2f3f5;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .tlt-name {
          .tag-name {
            font-weight: 600;
            font-size: 14px;
            margin-left: 20px;
          }
        }
        .tlt-price {
          font-size: 14px;
          color: #1890ff;
          font-weight: 600;
          margin-right: 20px;
        }
      }
      .fee-msg {
        background: #ffffff;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        width: 100%;
        padding-top: 20px;
        .msg {
          flex: 1;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          flex-wrap: wrap;
          margin-left: 20px;
          div {
            width: 33.33%;
            margin-bottom: 12px;
          }
          .msg-tlt {
            color: var(--color-neutral-10);
            span {
              color: var(--color-neutral-8);
            }
          }
          .times {
            width: 66.66%;
          }
        }
        .msg-open {
          color: #1890ff;
          font-size: 14px;
          margin-right: 20px;
          cursor: pointer;
        }
      }
      .line {
        width: 100%;
        background-color: #fbfbfc;
        div {
          width: calc(100% - 40px);
          margin-left: 20px;
          height: 1px;
          background-color: #f2f3f5;
        }
      }
      .amount-all {
        background-color: #fbfbfc;
        .amount {
          width: 100%;
          height: 62px;
          display: flex;
          justify-content: flex-end;
          align-items: center;
          padding-right: 20px;
        }
      }
      .fee-table {
        background: #f2f3f5;
        padding: 0 20px;
        margin: 20px 20px 0;
        .table-items {
          .item-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 62px;
            line-height: 62px;
            border-bottom: 1px solid #e2e4e5;
            .item-pro {
              width: 90px;
              text-overflow: ellipsis;
              overflow: hidden;
              white-space: nowrap;
            }
            .item-date {
              width: 120px;
            }
          }
        }
      }
    }
    .all-cost {
      font-weight: 600;
      padding: 20px;
      margin: 0 20px 20px;
      display: flex;
      justify-content: flex-end;
      background: #f2f3f5;
      height: 62px;
      color: #1890ff;
    }
  }
</style>
